IMotion.SetAxisCyclicSwitch method
Uses an axis' position to control a switch that triggers a digital output repeatedly. When an axis reaches a certain position, a switch is turned on or off. A switch can be controlled by a forward and backward movement of an axis.
Namespace: IntervalZero.KINGSTAR.Base.ApiAssembly: IntervalZero.KINGSTAR.Base.Api (in IntervalZero.KINGSTAR.Base.dll) Version: 4.4.0.0
Syntax
KsCommandStatus SetAxisCyclicSwitch(
int Index,
McOutput Output,
double StartPosition,
McCamSwitch CyclicSwitch,
McLengthType IntervalType,
double Interval,
McLengthType DurationType,
double Duration,
McSource ValueSource
)
Function SetAxisCamSwitch(
Index As Integer,
Output As McOutput,
StartPosition As Double,
CyclicSwitch As McCamSwitch,
McLengthType As IntervalType,
Interval As Double,
DurationType As McLengthType,
Duration As Double,
ValueSource As McSource
) As KsCommandStatus
Parameters
Index [in]
Type: int
The index of an axis. Indexes are zero based. Aliases affect this parameter.
Output [in]
Type: McOutput
Selects which digital output will be controlled by the corresponding track.
StartPosition [in]
Type: double
The position from which the cycle starts.
CyclicSwitch [in]
Type: McCamSwitch
Controls switching actions.
- TrackNumber: must be zero.
- FirstOnPosition: must be nonnegative. It is the distance relative to each cycle’s starting position.
- LastOnPosition: must be positive and greater than FirstOnPosition. It is the distance relative to each cycle’s starting position.
- Duration: must be positive.
IntervalType [in]
Type: McLengthType
The type of Interval. mcDistance and mcTime can be used.
Interval [in]
Type: double
The length of a cycle. It depends on the IntervalType you select. This value must be positive.
DurationType [in]
Type: McLengthType
The type of Duration. mcDistance and mcCount can be used.
Duration [in]
Type: double
The duration over which the cycle repeats. It depends on the DurationType you select. This value must be positive.
ValueSource [in]
Type: McSource
Defines the source for axis values. For example, positions. See McSource.
- mcCommandedValue, mcSetValue – synchronization on set value. We suggest you use these settings.
- mcActualValue – synchronization on actual value. This setting may not be stable.
- mcSecondEncoderValue – the actual value read from the second encoder.
Return value
Type: KsCommandStatus
Returns the KsCommandStatus class.
Remarks
- McCamSwitch is a vendor-specific class that defines switches for digital cam.
- McOutput is a vendor-specific structure linked to the (physical) outputs. If you are using your servo drive's digital output (DO), you need to use IApi.EnableAxisOutput before IApi.Start.
- In the McCamSwitch class, when CamSwitchMode is Position, the following combinations are not supported:
- IntervalType: mcTime, DurationType: mcDistance.
- IntervalType: mcTime, DurationType: mcCount.
- SetAxisCyclicSwitch is not affected when modulo axis is enabled. The axis doesn't treat the position as a modulo position. For example, with a modulo value of 360, if FirstOnPosition is set to 360 and LastOnPosition is set to 540, the trigger turns on when the axis rotates 1 cycle and turns off when the axis rotates 1.5 cycles. After enabling modulo axis, we recommend that users:
- Use SetAxisPositionOffset to reset the position, preventing discrepancies between the displayed and internal positions. For example, when the modulo axis value is set to 360, the user might see a position of 0, while the internal position is 360000.
- Use velocity or distance APIs to trigger the switch.
Examples
N/A
Use cases:
The following cases are in the RT/Win32 interface, but they help you understand how a cyclic switch work.
Case 1
A cyclic switch completes its task for the duration.
McOutput outputBit = {
FALSE, //Axis or IO module. FALSE = I/O.
0, //Index
0 //Offset
}
McCamSwitch cyclicSwitch = {
0, //TrackNumber
40, //FirstOnPosition
60, //LastOnPosition
1, //AxisDirection. 1 = Positive.
0, //CamSwitchMode. 0 = Position.
0 //Duration. It is not used in this case.
);
Command = SetAxisCyclicSwitch(
TargetAxis, //Index
outputBit, //Output
100, //StartPosition
cyclicSwitch, //CyclicSwitch
mcDistance, //IntervalType
100, //Interval
mcDistance, //DurationType
250, //Duration
mcSetValue //ValueSource
);
Case 2
A cyclic switch is aborted before it completes the task.
McOutput outputBit = {
FALSE, //Axis or IO module. FALSE = I/O.
0, //Index
0 //Offset
}
McCamSwitch cyclicSwitch = {
0, //TrackNumber
0, //FirstOnPosition
0, //LastOnPosition
1, //AxisDirection. 1 = Positive.
1, //CamSwitchMode. 1 = Time.
0.003 //Duration
);
Command = SetAxisCyclicSwitch(
TargetAxis, //Index
outputBit, //Output
100, //StartPosition
cyclicSwitch, //CyclicSwitch
mcTime, //IntervalType
0.005, //Interval
mcCount, //DurationType
3, //Duration
mcSetValue //ValueSource
);
See also